// var express = require("express")
// var db = require("./sql")
// const mysql = require("mysql")


// const app = express()

// app.use(express.static("../server"))

// var server = require("http").createServer(app)

// var conn = mysql.createConnection(db.mysql)
// conn.connect()

// app.all("*", function(request,response,next){
//     response.header("Access-Control-Allow-Origin","*")
// })

// app.get("/hotel/night", function(request, response){
//     conn.query("select * from night",function(err,results,fields){
//         if (err)throw err;
//         response.send(results)
//     })
// })

// server.listen(5000,(err)=>{
//     if (!err) console.log("listening 3000...");
// })

const mysql = require("mysql")
const express = require("express")
const app = express()

app.use(express.static("../server"))

const conn = mysql.createConnection({
    host: "localhost",
    user: "root",
    password: "123456",
    port: '3306',
    database: "world"
})
conn.connect()

app.get("/radar_lines", (request, response) => {
    conn.query("select * from city", (error, results, fields) => {
        if (error) throw error
        response.send(results)
        console.log("访问了radar_lines...");
    })
})

// app.get("/radar_lines", (request, response) => {
//     conn.query("select * from radar_lines", (error, results, fields) => {
//         if (error) throw error
//         response.send(results)
//         console.log("访问了radar_lines...");
//     })
// })
// app.get("/platform_rate", (request, response) => {
//     conn.query("select * from platform_rate", (error, results, fields) => {
//         if (error) throw error
//         response.send(results)
//         console.log("访问了platform_rate...");
//     })
// })
// app.get("/platform", (request, response) => {
//     conn.query("select * from platform", (error, results, fields) => {
//         if (error) throw error
//         response.send(results)
//         console.log(`${request.get("host")}访问了${request.url}...`);
//     })
// })
// app.get("/city_let_rate", (request, response) => {
//     conn.query("select * from city_let_rate", (error, results, fields) => {
//         if (error) throw error
//         response.send(results)
//         console.log("访问了city_let_rate...");
//     })
// })
// app.get("/night", (request, response) => {
//     conn.query("select * from night", (error, results, fields) => {
//         if (error) throw error
//         response.send(results)
//         console.log("访问了night...");
//     })
// })

app.listen(3000, () => {
    console.log("3000..");
})